﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using NiceManage.Models;
using SqlSugar;
namespace NiceManage.Common
{
    
    public class Users
    {
        SqlSugarClient db = DbHelper.GetInstance();
        public List<m_user> GetList()
        {
            return db.Queryable<m_user>().ToList();
        }

        public List<m_user> GetListPage(int pageIndex, int pageSize, ref int count)
        {
            return db.Queryable<m_user>().OrderBy(o => o.ID).ToPageList(pageIndex, pageSize,ref count);
        }
        public m_user Get_UserByID(int ID)
        {
            return db.Queryable<m_user>().Where(a => a.ID == ID).First();
        }

        internal int Add_User(m_user m_User)
        {
            return db.Insertable<m_user>(m_User).ExecuteCommand();
        }

        public int Delete_User(int ID)
        {
            return db.Deleteable<m_user>().Where(a => a.ID == ID).ExecuteCommand();
        }
        public int Update_User(m_user m_User)
        {
            return db.Updateable<m_user>(m_User).ExecuteCommand();
        }
    }
}
